<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/**
<span class='line'>  2</span>  * Returns a default number format.
<span class='line'>  3</span>  *
<span class='line'>  4</span>  * @class Represents a number format, converting between a &lt;tt>number&lt;/tt> and a
<span class='line'>  5</span>  * &lt;tt>string&lt;/tt>. This class allows numbers to be formatted with variable
<span class='line'>  6</span>  * precision (both for the integral and fractional part of the number), optional
<span class='line'>  7</span>  * thousands grouping, and optional padding. The thousands (",") and decimal
<span class='line'>  8</span>  * (".") separator can be customized.
<span class='line'>  9</span>  *
<span class='line'> 10</span>  * @returns {pv.Format.number} a number format.
<span class='line'> 11</span>  */</span><span class="WHIT">
<span class='line'> 12</span> </span><span class="NAME">pv.Format.number</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 13</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">mini</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// default minimum integer digits</span><span class="WHIT">
<span class='line'> 14</span> </span><span class="WHIT">      </span><span class="NAME">maxi</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Infinity</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// default maximum integer digits</span><span class="WHIT">
<span class='line'> 15</span> </span><span class="WHIT">      </span><span class="NAME">mins</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// mini, including group separators</span><span class="WHIT">
<span class='line'> 16</span> </span><span class="WHIT">      </span><span class="NAME">minf</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// default minimum fraction digits</span><span class="WHIT">
<span class='line'> 17</span> </span><span class="WHIT">      </span><span class="NAME">maxf</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// default maximum fraction digits</span><span class="WHIT">
<span class='line'> 18</span> </span><span class="WHIT">      </span><span class="NAME">maxk</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// 10^maxf</span><span class="WHIT">
<span class='line'> 19</span> </span><span class="WHIT">      </span><span class="NAME">padi</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"0"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// default integer pad</span><span class="WHIT">
<span class='line'> 20</span> </span><span class="WHIT">      </span><span class="NAME">padf</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"0"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// default fraction pad</span><span class="WHIT">
<span class='line'> 21</span> </span><span class="WHIT">      </span><span class="NAME">padg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// whether group separator affects integer padding</span><span class="WHIT">
<span class='line'> 22</span> </span><span class="WHIT">      </span><span class="NAME">decimal</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"."</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// default decimal separator</span><span class="WHIT">
<span class='line'> 23</span> </span><span class="WHIT">      </span><span class="NAME">group</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">","</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// default group separator</span><span class="WHIT">
<span class='line'> 24</span> 
<span class='line'> 25</span> </span><span class="WHIT">  </span><span class="COMM">/** @private */</span><span class="WHIT">
<span class='line'> 26</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 27</span> </span><span class="WHIT">    </span><span class="COMM">/* Round the fractional part, and split on decimal separator. */</span><span class="WHIT">
<span class='line'> 28</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">Infinity</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">maxf</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Math.round</span><span class="PUNC">(</span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">maxk</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NAME">maxk</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 29</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">String</span><span class="PUNC">(</span><span class="NAME">Math.abs</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">split</span><span class="PUNC">(</span><span class="STRN">"."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 30</span> 
<span class='line'> 31</span> </span><span class="WHIT">    </span><span class="COMM">/* Pad, truncate and group the integral part. */</span><span class="WHIT">
<span class='line'> 32</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"-"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 33</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">maxi</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">i.substring</span><span class="PUNC">(</span><span class="NAME">i.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">maxi</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 34</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">padg</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i.length</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">mini</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">(</span><span class="NAME">mini</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">i.length</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="NAME">padi</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 35</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">i.replace</span><span class="PUNC">(</span><span class="REGX">/\B(?=(?:\d{3})+(?!\d))/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">group</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 36</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">padg</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i.length</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">mins</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">(</span><span class="NAME">mins</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">i.length</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="NAME">padi</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 37</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 38</span> 
<span class='line'> 39</span> </span><span class="WHIT">    </span><span class="COMM">/* Pad the fractional part. */</span><span class="WHIT">
<span class='line'> 40</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">f</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 41</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">f.length</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">minf</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">f</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">(</span><span class="NAME">minf</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">f.length</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="NAME">padf</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 42</span> 
<span class='line'> 43</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s.join</span><span class="PUNC">(</span><span class="NAME">decimal</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 45</span> 
<span class='line'> 46</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'> 47</span>    * @function
<span class='line'> 48</span>    * @name pv.Format.number.prototype.format
<span class='line'> 49</span>    * @param {number} x
<span class='line'> 50</span>    * @returns {string}
<span class='line'> 51</span>    */</span><span class="WHIT">
<span class='line'> 52</span> </span><span class="WHIT">  </span><span class="NAME">format.format</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 53</span> 
<span class='line'> 54</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'> 55</span>    * Parses the specified string as a number. Before parsing, leading and
<span class='line'> 56</span>    * trailing padding is removed. Group separators are also removed, and the
<span class='line'> 57</span>    * decimal separator is replaced with the standard point ("."). The integer
<span class='line'> 58</span>    * part is truncated per the maximum integer digits, and the fraction part is
<span class='line'> 59</span>    * rounded per the maximum fraction digits.
<span class='line'> 60</span>    *
<span class='line'> 61</span>    * @function
<span class='line'> 62</span>    * @name pv.Format.number.prototype.parse
<span class='line'> 63</span>    * @param {string} x the string to parse.
<span class='line'> 64</span>    * @returns {number} the parsed number.
<span class='line'> 65</span>    */</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT">  </span><span class="NAME">format.parse</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">re</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.Format.re</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 68</span> 
<span class='line'> 69</span> </span><span class="WHIT">    </span><span class="COMM">/* Remove leading and trailing padding. Split on the decimal separator. */</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">String</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT">        </span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">RegExp</span><span class="PUNC">(</span><span class="STRN">"^("</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">re</span><span class="PUNC">(</span><span class="NAME">padi</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">")*"</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT">        </span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">RegExp</span><span class="PUNC">(</span><span class="STRN">"("</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">re</span><span class="PUNC">(</span><span class="NAME">padf</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">")*$"</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 73</span> </span><span class="WHIT">        </span><span class="PUNC">.</span><span class="NAME">split</span><span class="PUNC">(</span><span class="NAME">decimal</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 74</span> 
<span class='line'> 75</span> </span><span class="WHIT">    </span><span class="COMM">/* Remove grouping and truncate the integral part. */</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">RegExp</span><span class="PUNC">(</span><span class="NAME">re</span><span class="PUNC">(</span><span class="NAME">group</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"g"</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">maxi</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">i.substring</span><span class="PUNC">(</span><span class="NAME">i.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">maxi</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 78</span> 
<span class='line'> 79</span> </span><span class="WHIT">    </span><span class="COMM">/* Round the fractional part. */</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">f</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">(</span><span class="STRN">"0."</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">Infinity</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">maxf</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">f</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Math.round</span><span class="PUNC">(</span><span class="NAME">f</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">maxk</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NAME">maxk</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 82</span> 
<span class='line'> 83</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">Math.round</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">f</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 85</span> 
<span class='line'> 86</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'> 87</span>    * Sets or gets the minimum and maximum number of integer digits. This
<span class='line'> 88</span>    * controls the number of decimal digits to display before the decimal
<span class='line'> 89</span>    * separator for the integral part of the number. If the number of digits is
<span class='line'> 90</span>    * smaller than the minimum, the digits are padded; if the number of digits is
<span class='line'> 91</span>    * larger, the digits are truncated, showing only the lower-order digits. The
<span class='line'> 92</span>    * default range is [0, Infinity].
<span class='line'> 93</span>    *
<span class='line'> 94</span>    * &lt;p>If only one argument is specified to this method, this value is used as
<span class='line'> 95</span>    * both the minimum and maximum number. If no arguments are specified, a
<span class='line'> 96</span>    * two-element array is returned containing the minimum and the maximum.
<span class='line'> 97</span>    *
<span class='line'> 98</span>    * @function
<span class='line'> 99</span>    * @name pv.Format.number.prototype.integerDigits
<span class='line'>100</span>    * @param {number} [min] the minimum integer digits.
<span class='line'>101</span>    * @param {number} [max] the maximum integer digits.
<span class='line'>102</span>    * @returns {pv.Format.number} &lt;tt>this&lt;/tt>, or the current integer digits.
<span class='line'>103</span>    */</span><span class="WHIT">
<span class='line'>104</span> </span><span class="WHIT">  </span><span class="NAME">format.integerDigits</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">min</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">max</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>105</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">arguments.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>106</span> </span><span class="WHIT">      </span><span class="NAME">mini</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">(</span><span class="NAME">min</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT">      </span><span class="NAME">maxi</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">arguments.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">(</span><span class="NAME">max</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">mini</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT">      </span><span class="NAME">mins</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">mini</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">Math.floor</span><span class="PUNC">(</span><span class="NAME">mini</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">group.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>109</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>111</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">mini</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">maxi</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>113</span> 
<span class='line'>114</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>115</span>    * Sets or gets the minimum and maximum number of fraction digits. The
<span class='line'>116</span>    * controls the number of decimal digits to display after the decimal
<span class='line'>117</span>    * separator for the fractional part of the number. If the number of digits is
<span class='line'>118</span>    * smaller than the minimum, the digits are padded; if the number of digits is
<span class='line'>119</span>    * larger, the fractional part is rounded, showing only the higher-order
<span class='line'>120</span>    * digits. The default range is [0, 0].
<span class='line'>121</span>    *
<span class='line'>122</span>    * &lt;p>If only one argument is specified to this method, this value is used as
<span class='line'>123</span>    * both the minimum and maximum number. If no arguments are specified, a
<span class='line'>124</span>    * two-element array is returned containing the minimum and the maximum.
<span class='line'>125</span>    *
<span class='line'>126</span>    * @function
<span class='line'>127</span>    * @name pv.Format.number.prototype.fractionDigits
<span class='line'>128</span>    * @param {number} [min] the minimum fraction digits.
<span class='line'>129</span>    * @param {number} [max] the maximum fraction digits.
<span class='line'>130</span>    * @returns {pv.Format.number} &lt;tt>this&lt;/tt>, or the current fraction digits.
<span class='line'>131</span>    */</span><span class="WHIT">
<span class='line'>132</span> </span><span class="WHIT">  </span><span class="NAME">format.fractionDigits</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">min</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">max</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>133</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">arguments.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>134</span> </span><span class="WHIT">      </span><span class="NAME">minf</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">(</span><span class="NAME">min</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>135</span> </span><span class="WHIT">      </span><span class="NAME">maxf</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">arguments.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">(</span><span class="NAME">max</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">minf</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>136</span> </span><span class="WHIT">      </span><span class="NAME">maxk</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Math.pow</span><span class="PUNC">(</span><span class="NUMB">10</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">maxf</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>137</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>138</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>139</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">minf</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">maxf</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>140</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>141</span> 
<span class='line'>142</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>143</span>    * Sets or gets the character used to pad the integer part. The integer pad is
<span class='line'>144</span>    * used when the number of integer digits is smaller than the minimum. The
<span class='line'>145</span>    * default pad character is "0" (zero).
<span class='line'>146</span>    *
<span class='line'>147</span>    * @param {string} [x] the new pad character.
<span class='line'>148</span>    * @returns {pv.Format.number} &lt;tt>this&lt;/tt> or the current pad character.
<span class='line'>149</span>    */</span><span class="WHIT">
<span class='line'>150</span> </span><span class="WHIT">  </span><span class="NAME">format.integerPad</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>151</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">arguments.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>152</span> </span><span class="WHIT">      </span><span class="NAME">padi</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">String</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>153</span> </span><span class="WHIT">      </span><span class="NAME">padg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/\d/</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">padi</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>154</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>155</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>156</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">padi</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>157</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>158</span> 
<span class='line'>159</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>160</span>    * Sets or gets the character used to pad the fration part. The fraction pad
<span class='line'>161</span>    * is used when the number of fraction digits is smaller than the minimum. The
<span class='line'>162</span>    * default pad character is "0" (zero).
<span class='line'>163</span>    *
<span class='line'>164</span>    * @param {string} [x] the new pad character.
<span class='line'>165</span>    * @returns {pv.Format.number} &lt;tt>this&lt;/tt> or the current pad character.
<span class='line'>166</span>    */</span><span class="WHIT">
<span class='line'>167</span> </span><span class="WHIT">  </span><span class="NAME">format.fractionPad</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>168</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">arguments.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>169</span> </span><span class="WHIT">      </span><span class="NAME">padf</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">String</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>170</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>171</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>172</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">padf</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>173</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>174</span> 
<span class='line'>175</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>176</span>    * Sets or gets the character used as the decimal point, separating the
<span class='line'>177</span>    * integer and fraction parts of the number. The default decimal point is ".".
<span class='line'>178</span>    *
<span class='line'>179</span>    * @param {string} [x] the new decimal separator.
<span class='line'>180</span>    * @returns {pv.Format.number} &lt;tt>this&lt;/tt> or the current decimal separator.
<span class='line'>181</span>    */</span><span class="WHIT">
<span class='line'>182</span> </span><span class="WHIT">  </span><span class="NAME">format.decimal</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>183</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">arguments.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>184</span> </span><span class="WHIT">      </span><span class="NAME">decimal</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">String</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>185</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>186</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>187</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">decimal</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>188</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>189</span> 
<span class='line'>190</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>191</span>    * Sets or gets the character used as the group separator, grouping integer
<span class='line'>192</span>    * digits by thousands. The default decimal point is ",". Grouping can be
<span class='line'>193</span>    * disabled by using "" for the separator.
<span class='line'>194</span>    *
<span class='line'>195</span>    * @param {string} [x] the new group separator.
<span class='line'>196</span>    * @returns {pv.Format.number} &lt;tt>this&lt;/tt> or the current group separator.
<span class='line'>197</span>    */</span><span class="WHIT">
<span class='line'>198</span> </span><span class="WHIT">  </span><span class="NAME">format.group</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>199</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">arguments.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>200</span> </span><span class="WHIT">      </span><span class="NAME">group</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">String</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>201</span> </span><span class="WHIT">      </span><span class="NAME">mins</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">mini</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">Math.floor</span><span class="PUNC">(</span><span class="NAME">mini</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">group.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>202</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>203</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>204</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">group</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>205</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>206</span> 
<span class='line'>207</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>208</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>209</span> </span></pre></body></html>